package com.pmt.jnipractice

import android.content.Intent
import androidx.appcompat.app.AppCompatActivity
import android.os.Bundle
import android.widget.Button
import android.widget.TextView
import com.pmt.jnipractice.databinding.ActivityMainBinding

class MainActivity : AppCompatActivity() {

    private lateinit var binding: ActivityMainBinding

    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)

        binding = ActivityMainBinding.inflate(layoutInflater)
        setContentView(binding.root)

        // Example of a call to a native method
//        binding.sampleText.text = NativeUtils.stringFromJNI()
        binding.sampleText.text = NativeUtils.concatStrings("Hello", " World!")

        // 添加跳转到图像处理页面的按钮
        val imageProcessButton = Button(this).apply {
            text = "Go to Image Processing Demo"
        }

        binding.root.addView(imageProcessButton)

        imageProcessButton.setOnClickListener {
            startActivity(Intent(this, ImageProcessActivity::class.java))
        }

        // 测试字符串加密功能
        val originalText = "Hello World!"
        val shift = 3
        val encryptedText = NativeUtils.encryptString(originalText, shift)
        println("Original: $originalText")
        println("Encrypted with shift $shift: $encryptedText")
        binding.sampleText.text = encryptedText
    }
}